
	var loginToken = null;

(function($, owner) {
//var state =JSON.parse(localStorage.getItem('$state'));
//var stuIdToken = state.stuIdToken;
//var loginToken = state.loginToken;
	//发布商品
	owner.create_goods = function(goods) {
		owner.get_local_state();
		var url = GOODS_API + "/create.do";
		goods.loginToken = loginToken;
		return requestService.httpPost(url, goods);
	}

	//更新商品信息
	owner.update_goods = function(goods) {
		owner.get_local_state();
		var url = GOODS_API + "/update.do";
		goods.loginToken = loginToken;
		return requestService.httpPost(url, goods);
	}

	//删除商品
	owner.delete_goods = function(id) {
		owner.get_local_state();
		var url = GOODS_API + "/delete.do";
		var parms = {
			loginToken: loginToken,
			id: id
		};
		return requestService.httpGet(url,parms);

	}

	//查找指定商品
	owner.find_goods = function(id) {
		owner.get_local_state();
		var url = GOODS_API + "/find.do";
		var parms = {
			id: id,
			loginToken: loginToken,
		};
		return requestService.httpGet(url, parms);
	}
	//商品列表
	owner.all_goods_list = function() {
		var url = GOODS_API + "/list.do";
		return requestService.httpGet(url, null);
	}
	//查询我的商品列表
	owner.find_good_list = function() {
		owner.get_local_state();
		var url = GOODS_API + "/list.do";
		var parms = {
			loginToken: loginToken
		};
		return requestService.httpGet(url, parms);
	}
	
	//查询指定商品并带出默认地址
	owner.findGoodWihtAddress = function(id){
		owner.get_local_state();
		var url = GOODS_API +'/findGoodsWithAddress.do';
		var parms = {
			loginToken: loginToken,
			id:id,
		};
		return requestService.httpGet(url, parms);
	}
	owner.collectionGoods = function(goodsId){
		owner.get_local_state();
		var url = GOODS_API +'/collectionGoods.do';
		var parms = {
			loginToken: loginToken,
			goodsId:goodsId,
		}; 
		return requestService.httpGet(url, parms);
	}

	owner.cancelCollectionGoods = function(goodsId){
		owner.get_local_state();
		var url = GOODS_API +'/cancelCollectionGoods.do';
		var parms = {
			loginToken: loginToken,
			goodsId:goodsId,
		}; 
		return requestService.httpGet(url, parms);
	}
	owner.get_goods_list_by_goods_type =function (goodsType){
		var url = GOODS_API +'/getListByGoodsTye.do';
		var parms = {
			goodsType:goodsType
		}
		return requestService.httpGet(url, parms);
	}
	owner.get_campus_list = function(campus){
		var url = GOODS_API +'/findListByCampus.do';
		var parms ={
			campus:campus
		}
		return requestService.httpGet(url, parms);
	}
	
	owner.get_collection_list = function(){
		var url = GOODS_API +'/findCollectionList.do';
		owner.get_local_state();
		var parms ={
			loginToken: loginToken
		}
		return requestService.httpGet(url,parms);
	}
	
	owner.get_local_state = function() {
		var state = JSON.parse(localStorage.getItem('$state'));
		if(state != null) {
			loginToken = state.loginToken;
		}
	}
	
}(mui, window.goodsService = {}));